{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# load models"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%reload_ext autoreload\n",
    "%autoreload 2\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from fastai.text import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "wiki_path = \"data/wiki/\"\n",
    "wiki = load_learner(wiki_path, \"wiki-heb.pkl\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## load the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import codecs\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.random.seed(42)\n",
    "path_r = \"data/rivlin/\"\n",
    "data_frame = {}\n",
    "for i in [\"train\", \"test\"]:\n",
    "    data = list(codecs.open(f\"{path_r}/token_{i}.tsv\", 'r', 'utf-8').readlines())\n",
    "    x, y = zip(*[d.strip().split('\\t') for d in data])\n",
    "    data_frame[i] = pd.DataFrame({\"text\": x, \"label\": y, \"valid\": i==\"valid\"})\n",
    "\n",
    "# if you want to be carefull\n",
    "# msk = np.random.rand(len(data_frame[\"train\"])) < 0.8\n",
    "# train = data_frame[\"train\"][msk]\n",
    "# valid = data_frame[\"train\"][~msk]\n",
    "# len(train), len(valid), len(data_frame[\"test\"])\n",
    "\n",
    "dataframe = pd.concat([data_frame[\"train\"], data_frame[\"test\"]])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## language model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_lm = (TextList.from_df(dataframe, cols=[\"text\"])\n",
    "            .random_split_by_pct(0.2)\n",
    "            .label_for_lm()           \n",
    "            .databunch(bs=36))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: left;\">\n",
       "      <th>epoch</th>\n",
       "      <th>train_loss</th>\n",
       "      <th>valid_loss</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>6.285755</td>\n",
       "      <td>5.453011</td>\n",
       "      <td>0.223354</td>\n",
       "      <td>00:06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>5.388300</td>\n",
       "      <td>5.032595</td>\n",
       "      <td>0.245708</td>\n",
       "      <td>00:05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>4.586555</td>\n",
       "      <td>4.670845</td>\n",
       "      <td>0.264491</td>\n",
       "      <td>00:05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>3.740050</td>\n",
       "      <td>4.375226</td>\n",
       "      <td>0.299368</td>\n",
       "      <td>00:05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>3.143991</td>\n",
       "      <td>4.325456</td>\n",
       "      <td>0.306335</td>\n",
       "      <td>00:05</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "learn = language_model_learner(data_lm, AWD_LSTM,pretrained=wiki, drop_mult=0.3)\n",
    "learn.fit_one_cycle(5, 5e-2, moms=(0.8,0.7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: left;\">\n",
       "      <th>epoch</th>\n",
       "      <th>train_loss</th>\n",
       "      <th>valid_loss</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>2.883111</td>\n",
       "      <td>4.332112</td>\n",
       "      <td>0.309730</td>\n",
       "      <td>00:07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>2.778386</td>\n",
       "      <td>4.258980</td>\n",
       "      <td>0.322781</td>\n",
       "      <td>00:07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>2.657484</td>\n",
       "      <td>4.252689</td>\n",
       "      <td>0.327454</td>\n",
       "      <td>00:07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>2.546900</td>\n",
       "      <td>4.249361</td>\n",
       "      <td>0.327851</td>\n",
       "      <td>00:07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "learn.unfreeze()\n",
    "learn.fit_one_cycle(4, slice(1e-3), moms=(0.8,0.7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn.save_encoder(\"encoder_rivlin\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "data_class = TextClasDataBunch.from_df(\"\",vocab=learn.data.vocab, train_df=data_frame[\"train\"], valid_df=data_frame[\"test\"],# test_df=data_frame[\"test\"],\n",
    "                                      text_cols=[\"text\"], label_cols=[\"label\"], bs=32)\n",
    "learn_class = text_classifier_learner(data_class, AWD_LSTM, drop_mult=0.5)\n",
    "learn_class.load_encoder(\"encoder_rivlin\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LR Finder is complete, type {learner_name}.recorder.plot() to see the graph.\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deXxU9b3/8dcnO4GQEEhI2DfZdyKguKCl1h1xqVi1rrW3Wqveq7a9/d3aahettdpaq1IVtSq9Vdte17pVRUXEgLLIvhPIxpYFss/398dMIGA2Yc4smffz8ZgHM+ecOedzhmQ++e7mnENERGJXXLgDEBGR8FIiEBGJcUoEIiIxTolARCTGKRGIiMS4hHAH8FX16NHDDRgwINxhiIhElcWLF+90zmU1ty/qEsGAAQPIz88PdxgiIlHFzLa0tE9VQyIiMU6JQEQkxikRiIjEOCUCEZEYp0QgIhLjlAhERGKcEoGISIxTIhARiQK/f3sdH6wr9eTcSgQiIlHgwX+v4+MNuzw5txKBiEiEq2/wUe9zpCTGe3J+JQIRkQhXXe8DICXRm69szxKBmT1hZiVmtqKF/dPNrMzMPg88fupVLCIi0ay6rgHAsxKBl5POPQn8EXi6lWM+cM6d7WEMIiJR70AiSIiyqiHn3Hxgt1fnFxGJFdV1/qqh5GirGmqn48xsqZm9bmajWjrIzK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7EHgXefcrEB9+3tNdu877Bw1TZ430PzvTJ072NjW0jGtqXLOjTezdPwJ5QbgD/jXKsgCJjnn6sxsM5DSzPsN+LVz7tGveF0RQFVD0rG9iX+ufwDMrHEK4HRge+D5lR5efyH+KimA2W0d7Jwrw7905a1mlog/zpJAEjgF6B84tAJIa/LWN4CrA3PeY2a9zSw7SPcgMUCJQDqKVDMraPL4T/xfqnmBBtSV+KcPB/gN8Gsz+wiI9zCmm4H/NLNFQC5Q1tYbnHOf4Z+dcjb+BV/yzCwff+lgdeCYXcBHge6m9zrn3sRf9fSxmS0HXuDQRCHSKnUfFfFIYDW1KuecM7PZwCXOuZltvU8k1NRGIOKdScAfAz199hKi5UBFviqVCEREYpzaCEREYpwSgYhIjFMiEBGJcUoEIiIxTolARCTG/X8omqP6ygL7IAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "learn_class.lr_find()\n",
    "learn_class.recorder.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: left;\">\n",
       "      <th>epoch</th>\n",
       "      <th>train_loss</th>\n",
       "      <th>valid_loss</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>0.613803</td>\n",
       "      <td>0.470970</td>\n",
       "      <td>0.810547</td>\n",
       "      <td>00:07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>0.562804</td>\n",
       "      <td>0.440504</td>\n",
       "      <td>0.819922</td>\n",
       "      <td>00:07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>0.541959</td>\n",
       "      <td>0.423071</td>\n",
       "      <td>0.831641</td>\n",
       "      <td>00:07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "learn_class.fit_one_cycle(3, 1e-2, moms=(0.8,0.7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: left;\">\n",
       "      <th>epoch</th>\n",
       "      <th>train_loss</th>\n",
       "      <th>valid_loss</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>0.545800</td>\n",
       "      <td>0.415012</td>\n",
       "      <td>0.830469</td>\n",
       "      <td>00:08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>0.487235</td>\n",
       "      <td>0.415337</td>\n",
       "      <td>0.835938</td>\n",
       "      <td>00:08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>0.515618</td>\n",
       "      <td>0.423501</td>\n",
       "      <td>0.836328</td>\n",
       "      <td>00:08</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "learn_class.freeze_to(-2)\n",
    "learn_class.fit_one_cycle(3, slice(1e-4,1e-3), moms=(0.8,0.7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: left;\">\n",
       "      <th>epoch</th>\n",
       "      <th>train_loss</th>\n",
       "      <th>valid_loss</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>0.447228</td>\n",
       "      <td>0.378120</td>\n",
       "      <td>0.844141</td>\n",
       "      <td>00:10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>0.423068</td>\n",
       "      <td>0.350405</td>\n",
       "      <td>0.857031</td>\n",
       "      <td>00:11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>0.419075</td>\n",
       "      <td>0.379500</td>\n",
       "      <td>0.859766</td>\n",
       "      <td>00:11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "learn_class.freeze_to(-3)\n",
    "learn_class.fit_one_cycle(3, slice(1e-4,1e-3), moms=(0.8,0.7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: left;\">\n",
       "      <th>epoch</th>\n",
       "      <th>train_loss</th>\n",
       "      <th>valid_loss</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>0.409947</td>\n",
       "      <td>0.330528</td>\n",
       "      <td>0.870313</td>\n",
       "      <td>00:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>0.379117</td>\n",
       "      <td>0.326215</td>\n",
       "      <td>0.872656</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>0.367801</td>\n",
       "      <td>0.312985</td>\n",
       "      <td>0.886328</td>\n",
       "      <td>00:12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>0.364022</td>\n",
       "      <td>0.341326</td>\n",
       "      <td>0.885547</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>0.285569</td>\n",
       "      <td>0.293034</td>\n",
       "      <td>0.894141</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>0.295372</td>\n",
       "      <td>0.339370</td>\n",
       "      <td>0.894141</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>0.226642</td>\n",
       "      <td>0.291129</td>\n",
       "      <td>0.898047</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>0.197265</td>\n",
       "      <td>0.295951</td>\n",
       "      <td>0.907422</td>\n",
       "      <td>00:12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>0.199267</td>\n",
       "      <td>0.288218</td>\n",
       "      <td>0.913281</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9</td>\n",
       "      <td>0.189087</td>\n",
       "      <td>0.279940</td>\n",
       "      <td>0.917188</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "learn_class.unfreeze()\n",
    "learn_class.fit_one_cycle(10, slice(1e-3/(2.6**4),1e-3), moms=(0.8,0.7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn_class.save(\"rivlin\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: left;\">\n",
       "      <th>epoch</th>\n",
       "      <th>train_loss</th>\n",
       "      <th>valid_loss</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>0.218967</td>\n",
       "      <td>0.292004</td>\n",
       "      <td>0.913281</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>0.195559</td>\n",
       "      <td>0.275507</td>\n",
       "      <td>0.915625</td>\n",
       "      <td>00:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>0.237771</td>\n",
       "      <td>0.287703</td>\n",
       "      <td>0.914453</td>\n",
       "      <td>00:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>0.207441</td>\n",
       "      <td>0.286554</td>\n",
       "      <td>0.915234</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>0.191954</td>\n",
       "      <td>0.276237</td>\n",
       "      <td>0.919922</td>\n",
       "      <td>00:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>0.201283</td>\n",
       "      <td>0.284909</td>\n",
       "      <td>0.919922</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>0.174845</td>\n",
       "      <td>0.274808</td>\n",
       "      <td>0.915234</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>0.175277</td>\n",
       "      <td>0.341412</td>\n",
       "      <td>0.911328</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>0.180291</td>\n",
       "      <td>0.276024</td>\n",
       "      <td>0.921484</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9</td>\n",
       "      <td>0.154926</td>\n",
       "      <td>0.283394</td>\n",
       "      <td>0.923047</td>\n",
       "      <td>00:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>10</td>\n",
       "      <td>0.159741</td>\n",
       "      <td>0.276022</td>\n",
       "      <td>0.921094</td>\n",
       "      <td>00:12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>11</td>\n",
       "      <td>0.141133</td>\n",
       "      <td>0.275280</td>\n",
       "      <td>0.925781</td>\n",
       "      <td>00:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>12</td>\n",
       "      <td>0.152027</td>\n",
       "      <td>0.289006</td>\n",
       "      <td>0.923437</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>13</td>\n",
       "      <td>0.141510</td>\n",
       "      <td>0.274830</td>\n",
       "      <td>0.926953</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>14</td>\n",
       "      <td>0.122741</td>\n",
       "      <td>0.279118</td>\n",
       "      <td>0.925391</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>15</td>\n",
       "      <td>0.161232</td>\n",
       "      <td>0.276554</td>\n",
       "      <td>0.923047</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>16</td>\n",
       "      <td>0.143824</td>\n",
       "      <td>0.296886</td>\n",
       "      <td>0.923437</td>\n",
       "      <td>00:12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>17</td>\n",
       "      <td>0.143896</td>\n",
       "      <td>0.275202</td>\n",
       "      <td>0.926172</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>18</td>\n",
       "      <td>0.146237</td>\n",
       "      <td>0.279756</td>\n",
       "      <td>0.924219</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>19</td>\n",
       "      <td>0.147528</td>\n",
       "      <td>0.278737</td>\n",
       "      <td>0.926172</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "learn_class.fit_one_cycle(20, slice(1e-5,1e-4), moms=(0.8,0.7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: left;\">\n",
       "      <th>epoch</th>\n",
       "      <th>train_loss</th>\n",
       "      <th>valid_loss</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>0.153753</td>\n",
       "      <td>0.291420</td>\n",
       "      <td>0.923828</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>0.129646</td>\n",
       "      <td>0.282673</td>\n",
       "      <td>0.925000</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>0.131551</td>\n",
       "      <td>0.287922</td>\n",
       "      <td>0.926953</td>\n",
       "      <td>00:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>0.122028</td>\n",
       "      <td>0.280407</td>\n",
       "      <td>0.926562</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>0.171308</td>\n",
       "      <td>0.280694</td>\n",
       "      <td>0.929688</td>\n",
       "      <td>00:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>0.117863</td>\n",
       "      <td>0.279557</td>\n",
       "      <td>0.928125</td>\n",
       "      <td>00:12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>0.141222</td>\n",
       "      <td>0.283338</td>\n",
       "      <td>0.927344</td>\n",
       "      <td>00:12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>0.120557</td>\n",
       "      <td>0.289923</td>\n",
       "      <td>0.931641</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>0.124135</td>\n",
       "      <td>0.292608</td>\n",
       "      <td>0.928125</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9</td>\n",
       "      <td>0.129745</td>\n",
       "      <td>0.305329</td>\n",
       "      <td>0.927344</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>10</td>\n",
       "      <td>0.122194</td>\n",
       "      <td>0.305272</td>\n",
       "      <td>0.925781</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>11</td>\n",
       "      <td>0.141276</td>\n",
       "      <td>0.296914</td>\n",
       "      <td>0.928516</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>12</td>\n",
       "      <td>0.109011</td>\n",
       "      <td>0.293902</td>\n",
       "      <td>0.927344</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>13</td>\n",
       "      <td>0.125779</td>\n",
       "      <td>0.297789</td>\n",
       "      <td>0.928125</td>\n",
       "      <td>00:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>14</td>\n",
       "      <td>0.110376</td>\n",
       "      <td>0.298843</td>\n",
       "      <td>0.927344</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>15</td>\n",
       "      <td>0.135937</td>\n",
       "      <td>0.339851</td>\n",
       "      <td>0.921484</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>16</td>\n",
       "      <td>0.142346</td>\n",
       "      <td>0.338089</td>\n",
       "      <td>0.924219</td>\n",
       "      <td>00:12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>17</td>\n",
       "      <td>0.132895</td>\n",
       "      <td>0.298630</td>\n",
       "      <td>0.927734</td>\n",
       "      <td>00:14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>18</td>\n",
       "      <td>0.118116</td>\n",
       "      <td>0.295855</td>\n",
       "      <td>0.926172</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>19</td>\n",
       "      <td>0.121464</td>\n",
       "      <td>0.297782</td>\n",
       "      <td>0.928906</td>\n",
       "      <td>00:13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "learn_class.fit_one_cycle(20, slice(1e-6,1e-4), moms=(0.8,0.7))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "# p = learn_class.get_preds(ds_type = DatasetType.Test, ordered=True)\n",
    "# results = list(map(int, data_frame[\"test\"][\"label\"].values)) == np.argmax(p[0].numpy(), axis=1)\n",
    "# results.sum() / len(p[1])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
